package com.zjy.common.domain.model;


import com.zjy.common.domain.dto.RequestInfoDto;

/**
 * @author zhangjianyu
 * email: 578547270@qq.com
 * create_time: 2024-10-22 12:01
 * description:
 */
public class RequestHolder {

    private static final ThreadLocal<RequestInfoDto> threadLocal = new ThreadLocal<>();

    public static void set(RequestInfoDto requestInfo) {
        threadLocal.set(requestInfo);
    }

    public static RequestInfoDto get() {
        return threadLocal.get();
    }

    public static void remove() {
        threadLocal.remove();
    }

    /**
     * 获取后台用户id
     */
    public static Long getAdminUserId() {
        RequestInfoDto requestInfoDto = get();
        if (requestInfoDto != null) {
            return requestInfoDto.getAdminUserId();
        }
        return null;
    }
}
